<?php
if ($txn->txnid && $txn->ppid) {
  if (db_result(db_query("SELECT COUNT(txnid) FROM {ec_paypal} WHERE txnid = '%s'", $txn->txnid))) {
    db_query("UPDATE {ec_paypal} SET ppid = '%s', fee = '%s' WHERE txnid = '%d'", $txn->ppid, $txn->fee, $txn->txnid);
  }
  else {
    db_query("INSERT INTO {ec_paypal} (txnid, ppid, fee) VALUES (%d, '%s', '%s')", $txn->txnid, $txn->ppid, $txn->fee);
  }
}

